gtkaboutdialog.ui \
gtkdialog.ui \
gtkinfobar.ui \
+ gtklockbutton.ui \
gtkmessagedialog.ui
#
<file compressed="true">gtkaboutdialog.ui</file>
<file compressed="true">gtkdialog.ui</file>
<file compressed="true">gtkinfobar.ui</file>
+ <file compressed="true">gtklockbutton.ui</file>
<file compressed="true">gtkmessagedialog.ui</file>
</gresource>
</gresources>
g_object_unref (priv->icon_lock);
g_object_unref (priv->icon_unlock);
- g_object_unref (priv->label_group);
if (priv->cancellable != NULL)
{
GTK_TYPE_LOCK_BUTTON,
GtkLockButtonPrivate);
- priv->label_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
- priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_widget_set_halign (priv->box, GTK_ALIGN_CENTER);
- gtk_widget_set_valign (priv->box, GTK_ALIGN_CENTER);
- gtk_widget_show (priv->box);
- gtk_container_add (GTK_CONTAINER (button), priv->box);
- priv->image = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (priv->box), priv->image, FALSE, FALSE, 0);
- gtk_widget_show (priv->image);
- priv->label_lock = gtk_label_new ("");
- gtk_misc_set_alignment (GTK_MISC (priv->label_lock), 0, 0.5);
- gtk_widget_set_no_show_all (priv->label_lock, TRUE);
- gtk_widget_show (priv->label_lock);
- gtk_box_pack_start (GTK_BOX (priv->box), priv->label_lock, FALSE, FALSE, 0);
- gtk_size_group_add_widget (priv->label_group, priv->label_lock);
- priv->label_unlock = gtk_label_new ("");
- gtk_misc_set_alignment (GTK_MISC (priv->label_unlock), 0, 0.5);
- gtk_widget_set_no_show_all (priv->label_unlock, TRUE);
- gtk_box_pack_start (GTK_BOX (priv->box), priv->label_unlock, FALSE, FALSE, 0);
- gtk_size_group_add_widget (priv->label_group, priv->label_unlock);
+ gtk_widget_init_template (GTK_WIDGET (button));
names[0] = "changes-allow-symbolic";
names[1] = "changes-allow";
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /* Bind class to template
+ */
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/gtklockbutton.ui");
+ gtk_widget_class_bind_child (widget_class, GtkLockButtonPrivate, box);
+ gtk_widget_class_bind_child (widget_class, GtkLockButtonPrivate, image);
+ gtk_widget_class_bind_child (widget_class, GtkLockButtonPrivate, label_lock);
+ gtk_widget_class_bind_child (widget_class, GtkLockButtonPrivate, label_unlock);
+ gtk_widget_class_bind_child (widget_class, GtkLockButtonPrivate, label_group);
+
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LOCK_BUTTON_ACCESSIBLE);
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="gtk30">
+ <!-- interface-requires gtk+ 3.6 -->
+ <template class="GtkLockButton" parent="GtkButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <object class="GtkBox" id="box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-missing-image</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_lock">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Lock</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_unlock">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Unlock</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+ <object class="GtkSizeGroup" id="label_group">
+ <property name="mode">both</property>
+ <widgets>
+ <widget name="label_lock"/>
+ <widget name="label_unlock"/>
+ </widgets>
+ </object>
+</interface>
gtk_widget_destroy (infobar);
}
+static void
+test_lock_button_basic (void)
+{
+ GtkWidget *button;
+ GPermission *permission;
+
+ permission = g_simple_permission_new (TRUE);
+ button = gtk_lock_button_new (permission);
+ g_assert (GTK_IS_LOCK_BUTTON (button));
+ gtk_widget_destroy (button);
+ g_object_unref (permission);
+}
+
int
main (int argc, char **argv)
{
g_test_add_func ("/Template/GtkMessageDialog/Basic", test_message_dialog_basic);
g_test_add_func ("/Template/GtkAboutDialog/Basic", test_about_dialog_basic);
g_test_add_func ("/Template/GtkInfoBar/Basic", test_info_bar_basic);
+ g_test_add_func ("/Template/GtkLockButton/Basic", test_lock_button_basic);
return g_test_run();
}